package com.java46.carera.stock.enterstock.controller;

import com.github.pagehelper.PageInfo;
import com.java46.carera.base.entity.JsonResult;
import com.java46.carera.base.entity.PutStorage;
import com.java46.carera.base.entity.vo.PutStorageVo;
import com.java46.carera.base.util.JsonUtil;
import com.java46.carera.stock.enterstock.service.EnterStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName EnterStockController
 * @Description TODO
 * @Author Administrator
 * @Date 2018/8/23 0023 19:41
 * @Vcrsion 1.0
 **/
@RequestMapping("/stock/enterstock")
@Controller
public class EnterStockController {

    @Autowired
    private EnterStockService enterStockService;


    /**
     * @Author xiao
     * @Description //分页查询入库记录可根据关键字
     * @Date 23:06 2018/8/23 0023
     * @Param [pagenum, pagesize, keywords]
     * @return com.java46.carera.base.entity.JsonResult
     */
    @RequestMapping("/queryenterstock")
    @ResponseBody
    public JsonResult queryEnterStock(int pagenum, int pagesize, String keywords) throws Exception {

        PageInfo<PutStorageVo> puStorageVoPageInfo = enterStockService.queryEnterStock(pagenum, pagesize, keywords);
        JsonResult jsonResult = JsonUtil.setJsonResult(true, "查询成功", puStorageVoPageInfo);

        return jsonResult;
    }

    /**
     * @Author xiao
     * @Description //新增入库记录
     * @Date 23:06 2018/8/23 0023
     * @Param [putstorage]
     * @return com.java46.carera.base.entity.JsonResult
     */
    @RequestMapping("/insertenterstock")
    @ResponseBody
    public JsonResult insertEnterStock(PutStorage putstorage) throws Exception {

        enterStockService.insertEnterStock(putstorage);
        JsonResult jsonResult = JsonUtil.setJsonResult(true, "新增成功", null);
        return jsonResult;
    }


    /**
     * @Author xiao
     * @Description //删除入库记录
     * @Date 23:06 2018/8/23 0023
     * @Param [putid]
     * @return com.java46.carera.base.entity.JsonResult
     */
    @RequestMapping("/deleteenterstock")
    @ResponseBody
    public JsonResult deleteEnterStock(Integer putid) throws Exception {

        enterStockService.deleteEnterStock(putid);
        JsonResult jsonResult = JsonUtil.setJsonResult(true, "删除成功", null);
        return jsonResult;
    }

}
